using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations.Schema;
using System.Diagnostics.CodeAnalysis;
using System.Diagnostics.Contracts;
using System.Diagnostics.Tracing;
using System.Linq;
using System.Runtime.Serialization;
using System.Text.Json.Serialization;
using System.Xml.Serialization;
using Dapper.Contrib.Extensions;
using Microsoft.AspNetCore.Http;
using MongoDB.Bson.Serialization.Attributes;
using Publicuse.Entity.AttributeUtil;
using Publicuse.Entity.AttributeUtil.Validate;
using Publicuse.Entity.other;
using SqlSugar;

namespace Publicuse.Entity
{
  /// <summary>
  /// 基础数据
  /// </summary>
  public class BaseModel<T> : IBaseEntity
  {
    [Remark("创建人")]
    public string createuser { get; set; }

    [Remark("修改人")]
    public string modifyuser { get; set; }

    [Remark("备注")]
    public string Remark { get; set; } = string.Empty;

    [SugarColumn(IsIdentity = true, IsPrimaryKey = true)]
    [Remark("编号")]
    [PrimaryKey("Id")]
    [NoInsert]
    public T Id { get; set; }

    [Remark("状态")]
    public int status { get; set; } = 1;

    [Remark("更新时间")]
    public DateTime? uTime { get; set; } = null;

    [Remark("创建时间")]
    public DateTime cTime { get; set; } = DateTime.Now;

    [Remark("开始时间")]
    [Write(false)]
    [NoQuery]
    [SugarColumn(IsIgnore = true)]
    public string sttime { get; set; }

    [Remark("结束时间")]
    [Write(false)]
    [NoQuery]
    [SugarColumn(IsIgnore = true)]
    public string ettime { get; set; }

    [Remark("时间段")]
    [Write(false)]
    [NoQuery]
    [SugarColumn(IsIgnore = true)]
    public string lt { get; set; }

    [NoQuery]
    [NoInsert]
    [NoUpdate]
    [Remark("当前页码")]
    [Write(false)]
    [SugarColumn(IsIgnore = true)]
    public int pageIndex { get; set; } = 1;

    [NoQuery]
    [NoInsert]
    [NoUpdate]
    [Remark("当前显示条数")]
    [Write(false)]
    [SugarColumn(IsIgnore = true)]
    public int pageSize { get; set; } = 10;

    [NoQuery]
    [NoInsert]
    [NoUpdate]
    [Remark("查询字段")]
    [Write(false)]
    [SugarColumn(IsIgnore = true)]
    public string files { get; set; } = "*";

    [NoQuery]
    [NoInsert]
    [NoUpdate]
    [Remark("排序字段")]
    [Write(false)]
    [SugarColumn(IsIgnore = true)]
    public string sortFile { get; set; } = "Id";

    [NoQuery]
    [NoInsert]
    [NoUpdate]
    [Remark("排序类型")]
    [Write(false)]
    [SugarColumn(IsIgnore = true)]
    public string sortType { get; set; } = "desc";

    [NoQuery]
    [NoInsert]
    [NoUpdate]
    [Remark("登录编码")]
    [Write(false)]
    [SugarColumn(IsIgnore = true)]
    public string loginUserCode { get; set; }

    [NoQuery]
    [NoInsert]
    [NoUpdate]
    [Remark("登录token")]
    [Write(false)]
    [SugarColumn(IsIgnore = true)]
    public string loginToken { get; set; }

    [NoQuery]
    [NoInsert]
    [Write(false)]
    [SugarColumn(IsIgnore = true)]
    public string keyword { get; set; }

    public BaseModel()
    {
      this.loginUserCode = HttpContextExtendBase.GetLoginCode();
    }
  }

  public class ConfirmModel
  {
    public string Id { get; set; }

    public int status { get; set; }
  }

  /// <summary>
  /// 登录用户角色权限资源信息-按钮信息
  /// </summary>
  public class UserAction
  {
    public string name { get; set; }

    public string url { get; set; }

    public int type { get; set; }

    public string loginUserCode { get; set; }
  }

  /// <summary>
  /// 百度编辑器图片列表模型
  /// </summary>
  public class BDUEModel
  {
    public string state { get; set; }
    public List<bduM> list { get; set; }
    public int start { get; set; }
    public int size { get; set; }
    public int total { get; set; }

    public BDUEModel()
    {
      this.list = new List<bduM>();
    }
  }

  public class bduM
  {
    public string url { get; set; }
  }

  public class bduMExtend
  {
    public long time { get; set; }

    public string url { get; set; }
  }

  public enum DBType : int
  {
    ZS = 1,

    Test = 2
  }

  /// <summary>
  /// 读写分离
  /// </summary>
  public enum WriteAndReadEnum
  {
    Write,
    Read
  }

  /// <summary>
  /// 查询策略
  /// </summary>
  public enum QueryDBStrategyEnum
  {
    /// <summary>
    /// 随机
    /// </summary>
    Random,

    /// <summary>
    /// 轮询
    /// </summary>
    Polling
  }

  /// <summary>
  /// 业务操作类型
  /// </summary>
  public enum CUDType : int
  {
    //新增
    Add = 1,

    //修改
    Update = 2,

    //删除
    Delete = 3,

    //查询
    Query = 4
  }

  /// <summary>
  /// 数据库类别
  /// </summary>
  public enum DBConnectType : int
  {
    MySqlLocal = 1,

    MySqlZS = 2,

    MySqlTest = 3,

    MySqlRY = 16,

    SqlServerLocal = 4,

    SqlServerZS = 5,

    SqlServerTest = 6,

    OracleLocal = 7,

    OracleZS = 8,

    OracleTest = 9,

    MongodbLocal = 10,

    MongodbZS = 11,

    MongodbTest = 12,

    RedisLocal = 13,

    RedisZS = 14,

    RedisTest = 15,
  }
}
